﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace Corss_LehaKondr
{
    public class Ask:DependencyObject
    {
        AskCollection _ownerCollection;

        public string TextAsk
        {
            get { return (string)GetValue(TextAskProperty); }
            set { SetValue(TextAskProperty, value); }
        }

        // Using a DependencyProperty as the backing store for TextAsk.  This enables animation, styling, binding, etc...
        public static readonly DependencyProperty TextAskProperty =
            DependencyProperty.Register("TextAsk", typeof(string), typeof(Ask), new PropertyMetadata(""));



        public string Answer
        {
            get { return (string)GetValue(AnswerProperty); }
            set { SetValue(AnswerProperty, value); }
        }

        // Using a DependencyProperty as the backing store for Answer.  This enables animation, styling, binding, etc...
        public static readonly DependencyProperty AnswerProperty =
            DependencyProperty.Register("Answer", typeof(string), typeof(Ask), new PropertyMetadata(""));



        public uint Number
        {
            get { return (uint)GetValue(NumberProperty); }
            internal set { SetValue(NumberPropertyKey, value); }
        }

        // Using a DependencyProperty as the backing store for Number.  This enables animation, styling, binding, etc...
        internal static readonly DependencyPropertyKey NumberPropertyKey =
            DependencyProperty.RegisterReadOnly("Number", typeof(uint), typeof(Ask), new PropertyMetadata((uint)1));
        public static readonly DependencyProperty NumberProperty = NumberPropertyKey.DependencyProperty;



        internal void registerOwner(AskCollection owner)
        {
            if (_ownerCollection == null)
            {
                _ownerCollection = owner;
                haveOwner = true;
            }
            else
                throw new NotImplementedException();
        }

        internal void unregisterOwner(AskCollection owner)
        {
            if (_ownerCollection == owner)
            {
                _ownerCollection = null;
                haveOwner = false;

                ClearValue(NumberPropertyKey);
            }
            else
                throw new NotImplementedException();
        }

        public bool haveOwner { get; private set; }

        internal bool isOwner(AskCollection owner)
        {
            return object.ReferenceEquals(_ownerCollection, owner);
        }
    }
}
